<template>
	<view>
		<view class="echange_box" v-if="data !== undefined && data!== null && data.length>0">
			<view class="echange" v-if="data[0]" @click="info(data[0].balance_type_id,data[0].total,data[0].name)">
				<view class="echange_text">
					<text>{{data[0].name}}</text>
					<text class="total">{{data[0].total}}</text>
				</view>
				
			</view>
			<view class="echange" v-if="data[1]" @click="info(data[1].balance_type_id,data[1].total,data[1].name)">
				<view class="echange_text">
					<text>{{data[1].name}}</text>
					<text class="total">{{data[1].total}}</text>
				</view>
				
			</view>
			<view class="echange" v-if="data[2]" @click="info(data[2].balance_type_id,data[2].total,data[2].name)">
				<view class="echange_text">
					<text>{{data[2].name}}</text>
					<text class="total">{{data[2].total}}</text>
				</view>
				
			</view>
			<view class="echange" v-if="data[3]" @click="info(data[3].balance_type_id,data[3].total,data[3].name)">
				<view class="echange_text">
					<text>{{data[3].name}}</text>
					<text class="total">{{data[3].total}}</text>
				</view>
				<image src="@/static/tbsz.png" mode=""></image>
			</view>
		</view>
		<u-empty v-else mode="list" icon="/static/Empty/data_null.png">
		</u-empty>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				data: [],
			}
		},
		onShow() {
			this._request()
		},
		methods: {
			info(type, total, name) {
				uni.navigateTo({
					url: '/pages/mine/profit/profit_list?balance_type_id=' + type + '&total=' + total + '&name=' + name
				})
			},
			async _request() {
				const userinfo = uni.getStorageSync('userinfo');
				const {
					data: res
				} = await this.$myHttp({
					url: 'balance/getTypeTotal',
					// data: {},
					header: {
						'token': userinfo.token
					},
				});
				if (res.code == 1) {
					this.data = res.data
				} else {
					uni.showToast({
						title: res.msg,
						icon: 'none',
						duration: 3000
					})
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	.echange_box {
		padding: 30rpx;
		display: flex;
		flex-wrap: wrap;
		justify-content: space-between;

		.echange {
			width: 100%;
			padding: 20rpx;
			padding-bottom: 40rpx;
			
			box-sizing: border-box;
			border-radius: 15rpx;
			margin-bottom: 30rpx;
			color: #fff;
			font-size: 32rpx;
			display: flex;
			flex-direction: column;
			justify-content: space-between;
			align-items: flex-end;

			.echange_text {
				width: 100%;
				display: flex;
				flex-direction: column;
				align-items: flex-start;

				text:nth-child(1) {
					margin-bottom: 20rpx;
				}
				
				.total {
					font-size: 40rpx;
					font-weight: bold;
				}
			}

			text {
				display: block;
				width: 100%;
				text-align: start;
			}

			image {
				width: 60rpx;
				height: 60rpx;
			}
		}

		.echange:nth-child(5n+1) {
			background:url(/static/x_tb.png) no-repeat right,linear-gradient(to right, #7587f5, #a799fe);
			background-size: auto 100%;
		}

		.echange:nth-child(5n+2) {
			background:url(/static/h_tb1.png) no-repeat right bottom, linear-gradient(to right, #3eb7e0, #5df2e0);
			background-size: auto 100%;
		}

		.echange:nth-child(5n+3) {
			background:url(/static/tb_sz1.png) no-repeat right, linear-gradient(to right, #36ce86, #74ef8f);
			background-size: auto 100%;
		}

		.echange:nth-child(5n+4) {
			background:url(/static/x_tb.png) no-repeat right, linear-gradient(to right, #3eb7e0, #5df2e0);
			background-size: auto 100%;
		}

		.echange:nth-child(5n+5) {
			background: linear-gradient(to right, #7bdf8c, #a2eabc);
			background-size: auto 100%;
		}
	}
</style>